package com.gitee.jjnnzb.designpatterninspring.business.openapi.controller;

import com.gitee.jjnnzb.designpatterninspring.business.openapi.entity.bo.Source1Param;
import com.gitee.jjnnzb.designpatterninspring.business.openapi.entity.bo.Source2Param;
import com.gitee.jjnnzb.designpatterninspring.business.openapi.service.DataPushService;
import com.gitee.jjnnzb.designpatterninspring.common.bean.ResponseBean;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Jjn
 * @since 2023/8/10 18:49
 */
@RestController
@RequiredArgsConstructor
@Tag(name = "数据推送接口")
public class DataPushController {
    
    private final DataPushService dataPushService;
    
    @Operation(description = "渠道1推送数据接口", operationId = "渠道1")
    @PostMapping(value = "/api/v1/channel1/push/data")
    public ResponseBean<String> channel1(@RequestBody @Validated Source1Param source1Param) {
        dataPushService.handleChannel1PushedData(source1Param);
        return ResponseBean.success();
    }
    
    @Operation(description = "渠道2推送数据接口", operationId = "渠道2")
    @PostMapping(value = "/api/v1/channel2/push/data")
    public ResponseBean<String> channel2(@RequestBody @Validated Source2Param source2Param) {
        dataPushService.handleChannel2PushedData(source2Param);
        return ResponseBean.success();
    }
}
